#!/bin/bash
#
createEps()
{
    gnuplot<<EOF

    set terminal postscript eps enhanced color font 'Helvetica,40' linewidth 2\
        dl 8.0
    set output "blastFoam_rateStick_validation.eps"
    set datafile separator ","
    set xlabel "Inverse radius [1/mm]"
    set ylabel "Detonation velocity [m/s]"
    set grid
    set key right top
    set size 2,2
    set autoscale
    set xrange [0:0.20]
    plot    "$2" using 1:2 title 'Souers (2000)'\
                with points pt 5 ps 2 lc rgb 'blue',\
            "$3" using 1:2 title 'Guilikey et al. (2007)'\
                with points pt 7 ps 3 lc rgb 'black',\
            "$1" using 1:2 title 'blastFoam (JWL-C)'\
                with points pt 11 ps 5 lc rgb 'red'

EOF
}

# test if gnuplot exists on the system
if ! which gnuplot > /dev/null 2>&1
then
    echo "gnuplot not found - skipping graph creation" >&2
    exit 1
fi

# paths to data
# VALIDATIONDATAROOT=./validationData

cat ../rateStick_1D/detonationVelocity >blastFoam.csv
cat ../rateStick_6/detonationVelocity >>blastFoam.csv
cat ../rateStick_8/detonationVelocity >>blastFoam.csv
cat ../rateStick_12_5/detonationVelocity >>blastFoam.csv
cat ../rateStick_20/detonationVelocity >>blastFoam.csv

blastFOAM="blastFoam.csv"
exp="validationData/experimental_LNLL.csv"
sim="validationData/guilkey_et_al_2007.csv"


createEps $blastFOAM $exp $sim



echo Done
